package com.fjwt.gz.coupon.lkls;

import cn.hutool.json.JSONUtil;
import com.wechat.pay.java.core.notification.NotificationConfig;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@Service
@Slf4j
public class LklspayCouponWriteNotifyService {

    private static final Logger lklsPayLogger = LoggerFactory.getLogger("lklsPay");
    private static String logPrefix = "拉卡拉卡券核销回调:";

    public Map<String, Object> paraseParamters(HttpServletRequest request, NotificationConfig notificationConfig) throws IOException {
        lklsPayLogger.info(logPrefix + "request:{}", JSONUtil.toJsonStr(request));
        Map map = new HashMap<String, String>();
        Map<String, String[]> parameterMap = request.getParameterMap();
        for (Object key : parameterMap.keySet()) {
            map.put(key.toString(), ((String[]) parameterMap.get(key))[0]);
        }
        lklsPayLogger.info(logPrefix + "解析参数返回的信息是：{}", JSONUtil.toJsonStr(map));
        return map;
    }
}
